<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" exclude-result-prefixes="fo">
  <xsl:output method="xml" version="1.0" omit-xml-declaration="no" indent="yes"/>

<xsl:template match="people">
  <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
      <fo:layout-master-set>
        <fo:simple-page-master master-name="simpleA4" page-height="29.7cm" page-width="21cm" margin-top="2cm" margin-bottom="2cm" margin-left="2cm" margin-right="2cm">
          <fo:region-body/>
        </fo:simple-page-master>
      </fo:layout-master-set>
      <fo:page-sequence master-reference="simpleA4">
        <fo:flow flow-name="xsl-region-body">
        	
        	<fo:block font-weight="bold" font-size="14pt" text-align="center">People We Know</fo:block>
        	
        	<xsl:apply-templates select="person" />
        	
        </fo:flow>
       </fo:page-sequence>
    </fo:root>
</xsl:template>

<xsl:template match="person">

	<fo:block font-size="12pt" space-after="3mm" font-weight="bold"><xsl:apply-templates select="firstname" />&#160; <xsl:apply-templates select="lastname" /></fo:block>
    <fo:block font-size="12pt" space-after="3mm" margin-left="3mm"><xsl:apply-templates select="email" /></fo:block>
     <xsl:apply-templates select="bio" />
     <xsl:if test="spouse">
         <fo:block font-size="12pt" space-after="3mm" margin-left="3mm">Spouse: <fo:inline background-color="yellow"><xsl:apply-templates select="spouse" /></fo:inline></fo:block>
      </xsl:if>
      <xsl:choose>
		<xsl:when test="children">
			<fo:block font-size="12pt" space-after="6mm" margin-left="3mm">Children <xsl:apply-templates select="children/child"/></fo:block>
		</xsl:when>
		<xsl:otherwise>
			<fo:block font-size="12pt" space-after="6mm" margin-left="3mm">No children</fo:block>
		</xsl:otherwise>
	</xsl:choose>

</xsl:template>

<xsl:template match="bio">

	<fo:block font-size="10pt" font-style="italic"  border="1px outset blue" margin="3mm" padding="2mm"><xsl:apply-templates /></fo:block>

</xsl:template>

<xsl:template match="children/child">

	<fo:inline font-weight="bold" color="blue"><xsl:apply-templates  /></fo:inline>

</xsl:template>


</xsl:stylesheet>